<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {

   public function userLogin(){
        $adminModel=M('users');
        $num=$_POST['num'];
        $pass=md5($_POST['pass']);
        $users=$adminModel->where("pass='".$pass."' AND num='".$num."' ")->select();
        
        if($users){
          	session('users',$users);
            session('username',$users[0]['realname']);
            session('photo',$users[0]['photo']);
            session('users_id',$users[0]['id']);
            session('users_state',$users[0]['state']);
            session('num',$users[0]['num']);
            $this->redirect('./Home/Index/index');
        }else{
            $this->error("登录失败");
        }

    }
    public function userExit()
    {
        session('username',null); // 删除name
        session('photo',null); // 删除name
         session('photo',null);
         session('users',null);
         $this->redirect('./Home/Index/index');
    }
}